package com.openbravo.pos.reports;

import com.openbravo.basic.BasicException;
import com.openbravo.data.gui.ComboBoxValModel;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.QBFCompareEnum;
import com.openbravo.data.loader.SentenceList;
import com.openbravo.data.loader.SerializerWrite;
import com.openbravo.data.loader.SerializerWriteBasic;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppView;
import com.openbravo.pos.forms.DataLogicSales;

import java.awt.Component;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;

public class JParamsLocation extends JPanel
  implements ReportEditorCreator
{
  private SentenceList m_sentlocations;
  private ComboBoxValModel m_LocationsModel;
  private JLabel jLabel8;
  private JComboBox m_jLocation;

  public JParamsLocation()
  {
    initComponents();
  }

  public void init(AppView paramAppView)
  {
    DataLogicSales localDataLogicSales = (DataLogicSales)paramAppView.getBean("com.openbravo.pos.forms.DataLogicSales");
    this.m_sentlocations = localDataLogicSales.getLocationsList();
    this.m_LocationsModel = new ComboBoxValModel();
  }

  public void activate()
    throws BasicException
  {
    List localList = this.m_sentlocations.list();
    addFirst(localList);
    this.m_LocationsModel = new ComboBoxValModel(localList);
    this.m_LocationsModel.setSelectedFirst();
    this.m_jLocation.setModel(this.m_LocationsModel);
  }

  public SerializerWrite getSerializerWrite()
  {
    return new SerializerWriteBasic(new Datas[] { Datas.OBJECT, Datas.STRING });
  }

  public Component getComponent()
  {
    return this;
  }

  protected void addFirst(List paramList)
  {
  }

  public void addActionListener(ActionListener paramActionListener)
  {
    this.m_jLocation.addActionListener(paramActionListener);
  }

  public void removeActionListener(ActionListener paramActionListener)
  {
    this.m_jLocation.removeActionListener(paramActionListener);
  }

  public Object createValue()
    throws BasicException
  {
    return new Object[] { this.m_LocationsModel.getSelectedKey() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, this.m_LocationsModel.getSelectedKey() };
  }

  private void initComponents()
  {
    this.m_jLocation = new JComboBox();
    this.jLabel8 = new JLabel();
    setBorder(BorderFactory.createTitledBorder(AppLocal.getIntString("label.bywarehouse")));
    this.jLabel8.setText(AppLocal.getIntString("label.warehouse"));
    GroupLayout localGroupLayout = new GroupLayout(this);
    setLayout(localGroupLayout);
    localGroupLayout.setHorizontalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addComponent(this.jLabel8, -2, 110, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jLocation, -2, 220, -2).addContainerGap(-1, 32767)));
    localGroupLayout.setVerticalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel8).addComponent(this.m_jLocation, -2, 20, -2)).addContainerGap(13, 32767)));
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.reports.JParamsLocation
 * JD-Core Version:    0.6.0
 */